using System;
using System.Web.Caching;
using System.IO;
using System.Web;
using Castle.Windsor;
using log4net.Config;
using Rhino.Commons.Binsor;

namespace DecisionesInteligentes.iEvalua
{
	/// <summary>
	/// Bootstrap class for the application.
	/// </summary>
	public class Boot : HttpApplication, IContainerAccessor
    {
		private static IWindsorContainer container;

		public IWindsorContainer Container
		{
			get { return Boot.container; }
		}

		protected void Application_Start(Object sender, EventArgs e)
		{
			Boot.Initialize();
		}
		
		protected void Application_End(object sender, EventArgs e)
		{
			Boot.container.Dispose();
		}
		
		public static void Initialize()
		{
			XmlConfigurator.Configure();

			string binsorConfigFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "windsor.boo");
			container = new WindsorContainer();
			BooReader.Read(container, binsorConfigFilePath);
		}
	}
}

